/*
**  Copyright (c) 2014 Michael Liu(michael.liu.point@gmail.com).
**
**  Project: Gateway Unified Management Platform
**  File:    dpdev.h
**  Author:  Michael
**  Date:    06/24/2014
**
**  Purpose:
**    data path devices defines.
*/

#ifndef __DATAPATH_DEV_MGR_H__
#define __DATAPATH_DEV_MGR_H__

#ifdef __cplusplus
extern "C" {
#endif				/* __cplusplus */

/* Include files. */

#include "common.h"
#include "cmrc.h"
#include "list.h"

/* Macro constant definitions. */

#define DP_DEV_NAMESIZE							(16)
#define DP_DEV_REF_IF_MAX						(8)

/* Type definitions. */

	typedef struct dp_dev tdp_dev;
	struct dp_dev {
		char name[DP_DEV_NAMESIZE];
		unsigned char prepare;	/* eBOOL_TURE or eBOOL_FALSE */
		tdp_dev *based_on_dev;	/* based on dev pointer. */
		unsigned char ref_ifs_cnt;
		void *ref_ifs[DP_DEV_REF_IF_MAX];	/* reference interface array. */
		void *priv;
		 e_ret(*add_ref_if) (tdp_dev * me, void *ref_if);
		 e_ret(*del_ref_if) (tdp_dev * me, void *ref_if);
		 e_ret(*init) (tdp_dev * dp_dev);
		 e_ret(*clean) (tdp_dev * dp_dev);
	};

	typedef struct devmac tdevmac;
	struct devmac {
		char lan_mac[RC_MAC_STR_MAX_SIZE];
		char wlan_24G_mac[RC_MAC_STR_MAX_SIZE];
		char wlan_5G_mac[RC_MAC_STR_MAX_SIZE];
	};

/* External function declarations. */

	extern e_ret dp_dev_prepare(tdp_dev * dp_dev,
				    e_ret(*init) (tdp_dev * dp_dev), e_ret(*clean) (tdp_dev * dp_dev));

/* Macro API definitions. */

#define dp_dev_do_cmd(dp_dev, cmd, arg...) \
({																			\
	e_ret ret;																\
	if (dp_dev->cmd == NULL) {												\
		sysmgr_err("data path device [%s] has no [%s] capability.\n",		\
			(dp_dev)->name, #cmd);											\
		ret = eRET_SUCCESS;													\
	} else {																\
		ret = (dp_dev)->cmd((dp_dev), ##arg);								\
	}																		\
	ret;																	\
})

/* Global variable declarations. */

#ifdef __cplusplus
}				/* extern "C" */
#endif				/* __cplusplus */
#endif				/* __DATAPATH_DEV_MGR_H__ */
